'use strict';

module.exports = app => {
  const { INTEGER, DATE, BOOLEAN, STRING } = app.Sequelize;

  return app.model.define('file', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    user: {
      type: INTEGER,
      references: {
        model: app.model.User,
        key: 'id',
      },
      onUpdate: 'CASCADE',
      onDelete: 'CASCADE',
    },
    name: STRING(255),
    mime: STRING(255),
    folder_type: BOOLEAN,
    folder: {
      type: INTEGER,
      references: {
        model: app.model.File,
        key: 'id',
      },
      onUpdate: 'CASCADE',
      onDelete: 'CASCADE',
    },
    created_at: DATE,
    updated_at: DATE,
  });
};
